﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Profile.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content2" ContentPlaceHolderID="contentPane" runat="server">
    <div id='update-status' class="tabControl">
        <script type="text/javascript">
            $(document).ready(function () {
                $('#submit-new-status').click(function () {
                    // Params taken from http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/
                    var params = {};
                    params['message'] = $('#input-new-status').val(); ;
                    if (params['message'] == '') return;
                    /*
                    params['name'] = 'Name';
                    params['description'] = 'Description';
                    params['link'] = 'http://apps.facebook.com/summer-mourning/';
                    params['picture'] = 'http://summer-mourning.zoocha.com/uploads/thumb.png';
                    params['caption'] = 'Caption';
                    */

                    FB.api('/me/feed', 'post', params, function (response) {
                        if (!response || response.error) {
                            console.log('Error occured posting a message');
                        } else {
                            console.log('Post ID: ' + response.id);
                            location.reload();
                        }
                    });
                });
            });



            function facebookReady() {
                var accessToken = $("#authToken").val();

            }

        </script>
        Status:
        <textarea rows='2' cols='4' id='input-new-status'></textarea>
        <!-- I feel liek this should be here, but I don't see any options for it -->
        <!--
        <select id='status-permissions'>
            <option>Public</option>
            <option>Friends</option>
            <option>Only Me</option>
        </select>
        -->
        <input type="button" id='submit-new-status' value='Post' />
    </div>
    <%
        List<WebApp.Models.Post> posts = (List<WebApp.Models.Post>)ViewData["Model"];
        WebApp.Models.Photo photo;
        foreach (WebApp.Models.Post post in posts)
        {
    %>
    <div class="post">
        <ul>
            <%
            if (post.Type == "photo")
            {
                photo = post.Photo;
            %>
            <br />
            <li><a href="<%=post.Link %>">
                <img alt="<%=photo.Source %>" src="<%=photo.Source %>" /></a>
                <%=photo.Name %>
            </li>
            <%
            }
            else if (post.Type == "status")
            {
            %>
            <br />
            <%=post.Message%>
            --
            <%=post.Story%>
            <%
            } %>
        </ul>
    </div>
    <%
        }
    %>
</asp:Content>
